package com.iwe3.protal.config;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.nio.charset.Charset;

@EnableAspectJAutoProxy
@EnableTransactionManagement
@Configuration
public class AppConfig {

    @Bean
    public BloomFilter<String> bloomFilter(){
        //创建布隆过滤器
        //参数一：Funnels.stringFunnel(Charset.defaultCharset()) 设置字符集
        //参数二：设置过滤器允许存在多少个合法KEY
        //参数三：设置误差率
        return BloomFilter.create(
                Funnels.stringFunnel(Charset.defaultCharset()),
                100000,
                0.0001);
    }
}
